package com.celestial.Repository;

import com.celestial.Domain.DTO.StartAndEndNodes;
import com.celestial.Domain.PO.Institute;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface InstituteRepository extends Neo4jRepository<Institute, Long> {
    @Query("MATCH (n:`机构`)-[r]-(m) WHERE n.name = :#{#instituteName} "
            + "RETURN n.name AS startNode, collect(r), collect(m.name) AS endNode, collect(type(r)) AS relation")
    StartAndEndNodes getInstituteGraph(String instituteName);

    @Query("MATCH (n:`机构`) RETURN n.name")
    List<String> getAllInstitute();
}
